<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%String path = request.getContextPath();%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<%@ taglib uri="/WEB-INF/tld/sys.tld" prefix="sys" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>资管资产赎回记录</title>
    <jsp:include page="../../import.jsp" flush="true"/>
</head>

<script type="text/javascript">
    var grid = null;
    $(function () {
        initGrid();//grid
        $("#searchBar").ligerForm();
        $("#searchBtn").click(function (event) {
            var form = new liger.get("searchBar");
            var data = form.getData();
            for (name in data) {
                grid.setParm(name, data[name]);
            }
            grid.reload();
        });

    });

    function clearBtn() {
        $("#searchBar").ligerForm();
        var insCode = liger.get("insCode");
        insCode.selectValue(" ");
        var suretySubjectCode = liger.get("suretySubjectCode");
        suretySubjectCode.selectValue(" ");
        var form = new liger.get("searchBar");
        form.setData({
            lsCntNo : " ",
            cstNm: " ",
            crCntNo: " "
        });
    }

    //初始化列表
    function initGrid() {
        var params = {};
        $("#grid").ligerGrid({
            url: '<%=path%>/institution/prjinsredminfo/initAssetsRedmList.do',
            method: 'get',
            parms: params,
            columns: [
                {display: '合同号', name: 'lsCntNo', minWidth: 60, align: 'center', enabledSort: true},
                {display: '承租人名称', name: 'cstNm', minWidth: 100, align: 'center', enabledSort: true},
                {display: '第三方机构', name: 'fundRasInsNm', minWidth: 80, align: 'center', enabledSort: true},
                {
                    display: '赎回时间', name: 'redmTm', minWidth: 80, align: 'center', enabledSort: true,
                    render: function (rowdata, index, value) {
                        return renderDate(rowdata, index, rowdata.redmTm);
                    }
                },
                {display: '回购主体', name: 'suretySubjectNm', minWidth: 80, align: 'left', enabledSort: true},
                {
                    display: '赎回节点', name: 'redmTypCd', minWidth: 80, align: 'center', enabledSort: true,
                    render: function (rowdata, rowindex, value) {
                        var redmTypCd = rowdata.redmTypCd == null ? " " : rowdata.redmTypCd;
                        if (redmTypCd == 1) {
                            return "贷前(项目流程)";
                        }else if(redmTypCd == 2){
                            return "贷中(放款流程)";
                        }else if(redmTypCd == 3){
                            return "贷后(已赎回)";
                        }else if(redmTypCd == 4){
                            return "线下(OA)";
                        }else if(redmTypCd == 5){
                            return "贷后(已转回)";
                        }

                    }
                },
                {
                    display: '申请单号', name: 'flowId', minWidth: 80, align: 'center',
                    render: function (rowdata, rowindex, value, column) {
                        var pInstId = rowdata.pInstId == null ? " " : rowdata.pInstId;
                        var h = '';
                        if (pInstId == " ") {
                            h += "";
                        } else {
                            h += '<a href="javascript:commShowFlow(';
                            h += "'" + rowdata.pInstId + "',";
                            h += "'" + rowdata.audStsCd + "',";
                            h += "'" + rowdata.id + "'";
                            h += ')">' + rowdata.pNo + '</a>'
                        }
                        return h;
                    }, enabledSort: true
                }
            ],
            pageSize: 10,
            root: 'rows',
            record: 'total',
            hideLoadButton: true,
            width: '100%',
            height: '100%',
            heightDiff: -2,
            checkbox: true,
            allowUnSelectRow: true,
            alternatingRow: true,
            rownumbers: true,
            enabledEdit: true,
            usePagerOnLessPagesize: true,
        });
        grid = liger.get("grid");
        grid.setHeight(500);

    }

    //格式化为人民币格式
    function renderAmt(rowdata, rowindex, value) {
        var h = "￥" + FormatMoney(value);
        return h;
    }

    //格式化时间
    function renderDate(rowdata, index, value) {
        var dateStr = "";
        if (null != value && value != '') {
            var date = new Date(value);
            dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DD);
        }
        return dateStr;
    }
    //显示流程：流程实例ID,状态,业务主键(赎回ID)
    function commShowFlow(_pInstId, _audStsCd, _businessKey){
        if(StringUtils.isEmpty(_pInstId)){
            UIUtils.alertWarning(CommonConstant.C_P_INSTANCEID_NOT_HERE);
            return;
        }
        var _formUrl = "/institution/prjinsredminfo/toRedmInfoPage.do?redmId=";
        var params = "?pInsId="+_pInstId+"&status="+_audStsCd+"&businessKey="+_businessKey+"&formUrl="+_formUrl;
        Add_navTab('tab_ins_redm_flow_'+_businessKey,'查看流程',"<%=path%>/flow/flow/toFlowShowPageFowBus.do"+params);
    }

</script>

<body class="iframeBody">
<div class="Wrapper">
    <div id="pageInTab" class="pageInTab">
        <div class="searchArea">
            <form id="searchBar">
                <div class="fieldset1 clearFix">
                    <div class="fieldBox col_33" id="searchCstNm">
                        <div class="label">合同号</div>
                        <div class="field">
                            <input name="lsCntNo" id="lsCntNo" type="text" class="ui-textbox" value="">
                        </div>
                    </div>
                    <div class="fieldBox col_33" id="searchCstNmId">
                        <div class="label">承租人名称</div>
                        <div class="field">
                            <input name="cstNm" id="cstNm" type="text" class="ui-textbox" value="">
                        </div>
                    </div>
                    <div class="fieldBox col_33" <sys:resourceAuth resCd="noThdOrg">style="display: none" </sys:resourceAuth>>
                        <div class="label">第三方机构</div>
                        <div class="field">
                            <select name="insCode" id="insCode">
                                <option value=" " selected="selected">--请选择--</option>
                                <c:forEach items="${insCdList}" var="opt">
                                    <option value="${opt.insCode}">${opt.fundRasInsNm}</option>
                                </c:forEach>
                            </select>
                        </div>
                    </div>
                    <div class="fieldBox col_33">
                        <div class="label">回购主体</div>
                        <div class="field">
                            <select name="suretySubjectCode" id="suretySubjectCode">
                                <option value=" " selected="selected">--请选择--</option>
                                <c:forEach items="${suretySubjectCodeList}" var="opt">
                                    <option value="${opt.key}">${opt.value}</option>
                                </c:forEach>
                            </select>
                        </div>
                    </div>
                     <!--<div class="fieldBox col_33" id="searchCstNmId">
                        <div class="label">小贷账单</div>
                        <div class="field">
                            <input name="crCntNo" id="crCntNo" type="text" class="ui-textbox" value="">
                        </div>
                    </div>-->
                    <div class="clearFix"></div>
                    <div class="btnsBox">
                        <span id="searchBtn" class="sq-button sq-button-round">查询</span>
                        <span id="clearBtn" onclick="clearBtn();" class="sq-button sq-button-round">清空</span>
                    </div>
                </div>
            </form>
        </div>
        <div id="grid" class="sq-grid"></div>

    </div>
</div>
</div>
</body>
</html>